<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
	<xsl:template match="/">
		<xsl:choose>
			<xsl:when test="insupost-response/response-head/trans-type = 104">
				<ABCB2I>
					<xsl:for-each select="insupost-response">
						<Header>
							<xsl:call-template name="TransResultCode">
								<xsl:with-param name="srcCode" select="response-head/trans-result" />
							</xsl:call-template>
							<RetMsg>
								<xsl:for-each select="response-head/validity-errors/validity-error">
									<xsl:value-of select="error-desc" />
								</xsl:for-each>
								<xsl:for-each select="response-underwriting/uw-errors/uw-error">
									<xsl:value-of select="error-desc" />
								</xsl:for-each>
								<xsl:for-each select="response-underwriting/errors/error">
									<xsl:value-of select="error-desc" />
								</xsl:for-each>
							</RetMsg>
							<SerialNo>
								<xsl:value-of select="response-head/trans-id" />
							</SerialNo>
							<InsuSerial>
								<xsl:value-of select="response-head/trans-id" />
							</InsuSerial>
							<TransDate>
								<xsl:value-of select="translate(string(response-head/trans-date),'-','')" />
							</TransDate>
							<TransTime>
								<xsl:value-of select="translate(string(response-head/trans-time),':','')" />
							</TransTime>
							<BankCode>
								<xsl:value-of select="response-head/bank" />
							</BankCode>
							<CorpNo>
								<xsl:value-of select="response-head/insu-id" />
							</CorpNo>
							<TransCode>1002</TransCode>
						</Header>
						<App>
							<Ret>
								<PolicyNo>
									<xsl:value-of select="response-underwriting/uw-policy/policy-code" />
								</PolicyNo>
								<CompName>珠江人寿保险股份有限公司</CompName>
								<Prem>
									<xsl:choose>
										<xsl:when test="response-head/trans-result = 000000">
											<xsl:choose>
												<xsl:when test="normalize-space(response-underwriting/uw-policy/discount-prem)">
													<xsl:value-of select="response-underwriting/uw-policy/discount-prem" />
												</xsl:when>
											</xsl:choose>
										</xsl:when>
									</xsl:choose>
								</Prem>
							</Ret>
						</App>
					</xsl:for-each>
				</ABCB2I>
			</xsl:when>
		</xsl:choose>
	</xsl:template>
	<xsl:template name="TransResultCode">
		<xsl:param name="srcCode" />
		<xsl:choose>
			<xsl:when test="$srcCode = 0">
				<RetCode>000000</RetCode>
			</xsl:when>
			<xsl:when test="$srcCode = 4">
				<RetCode>009999</RetCode>
			</xsl:when>
			<xsl:otherwise>
				<RetCode>009990</RetCode>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
</xsl:stylesheet>
